var xmlHttp;

function showDivisions(countryID, site) {
	xmlHttp = getXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = "./scripts/hoc/getDivisions.php";
	url = url + "?country=" + countryID  + "&site=" + site;
	xmlHttp.onreadystatechange = changeDivisions;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function changeDivisions() {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById("divileag").innerHTML = xmlHttp.responseText;
	}
}

function showLeagues(countryID, divisionID, site) {
	xmlHttp = getXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = "./scripts/hoc/getLeagues.php";
	//var countryID = document.getElementById("select_countries").value;
	url = url + "?country=" + countryID + "&division=" + divisionID + "&site=" + site;
	xmlHttp.onreadystatechange = changeLeagues;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function changeLeagues() {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById("leagues").innerHTML = xmlHttp.responseText;
	}
}

function showYears(month, year) {
	xmlHttp = getXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = "./scripts/hoc/getYears.php";
	url = url + "?month=" + month + "&year=" + year;
	xmlHttp.onreadystatechange = changeYears;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function changeYears() {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById("years").innerHTML = xmlHttp.responseText;
	}
}

function showAllianceInput(alliance) {
	xmlHttp = getXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = "./scripts/hoc/getAllianceInput.php";
	url = url + "?alliance=" + alliance;
	xmlHttp.onreadystatechange = changeFedImport;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function changeFedImport() {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById("alliance").innerHTML = xmlHttp.responseText;
	}
}

function getXmlHttpObject() {
	var xmlHttp = null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
		//Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}